webpackJsonp([16],{

/***/ 0:
/***/ (function(module, exports, __webpack_require__) {


window._ = __webpack_require__(2);

/**
 * We'll load jQuery and the Bootstrap jQuery plugin which provides support
 * for JavaScript based Bootstrap features such as modals and tabs. This
 * code may be modified to fit the specific needs of your application.
 */

/*try {
    window.$ = window.jQuery = require('jquery');

    require('bootstrap-sass');
} catch (e) {}*/

/**
 * We'll load the axios HTTP library which allows us to easily issue requests
 * to our Laravel back-end. This library automatically handles sending the
 * CSRF token as a header based on the value of the "XSRF" token cookie.
 */

window.axios = __webpack_require__(3);

window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';

/**
 * Next we will register the CSRF Token as a common header with Axios so that
 * all outgoing HTTP requests automatically have it attached. This is just
 * a simple convenience so we don't have to attach every token manually.
 */

var token = document.head.querySelector('meta[name="csrf-token"]');

if (token) {
  window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
} else {
  console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
}

/**
 * Echo exposes an expressive API for subscribing to channels and listening
 * for events that are broadcast by Laravel. Echo and event broadcasting
 * allows your team to easily build robust real-time web applications.
 */

// import Echo from 'laravel-echo'

// window.Pusher = require('pusher-js');

// window.Echo = new Echo({
//     broadcaster: 'pusher',
//     key: 'your-pusher-key'
// });

/***/ }),

/***/ 1:
/***/ (function(module, exports) {

//设置toastr选项
toastr.options = {
    "closeButton": true,
    "debug": false,
    "progressBar": true,
    "preventDuplicates": false,
    "positionClass": "toast-top-right",
    "onclick": null,
    "showDuration": "400",
    "hideDuration": "1000",
    "timeOut": "1000",
    "extendedTimeOut": "1000",
    "showEasing": "swing",
    "hideEasing": "linear",
    "showMethod": "fadeIn",
    "hideMethod": "fadeOut"
};
window.utils = {
    /**
     *
     * @param data json响应数据
     * @param loadtag 载入标签
     */
    showToastr: function showToastr(data) {
        var loadtag = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';

        switch (data.status) {
            case 'success':
                toastr.success(data.message, data.title);
                break;
            case 'error':
                toastr.error(data.message, data.title);
                break;
            case 'info':
                toastr.info(data.message, data.title);
                break;
            default:
                toastr.warning(data.message, data.title);
                break;
        }
        if (data.status == 'success') {
            switch (loadtag) {
                case 'reload':
                    utils.reload(data.jumpTime);
                    break;
                case 'goback':
                    utils.goback(data.jumpTime);
                    break;
                case 'go':
                    if (data.url) {
                        utils.redirect(data.url, data.jumpTime);
                    }
                    break;
                default:
                    break;
            }
        }
    },
    bootstraptableOptions: {
        url: '', //请求地址
        method: 'get', //请求方式（*）
        toolbar: '#toolbar', //工具按钮用哪个容器
        striped: true, //是否显示行间隔色
        cache: false, //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
        pagination: true, //是否显示分页（*）
        sortable: false, //是否启用排序
        sortOrder: "asc", //排序方式
        sidePagination: "server", //分页方式：client客户端分页，server服务端分页（*）
        pageNumber: 1, //初始化加载第一页，默认第一页
        pageSize: 10, //每页的记录行数（*）
        pageList: [10, 25, 50, 100], //可供选择的每页的行数（*）
        paginationFirstText: "首页",
        paginationPreText: "上一页", //分页条中上一页按钮的图标或文字
        paginationNextText: "下一页", //分页条中下一页按钮的图标或文字
        paginationLastText: "尾页",
        queryParamsType: "", //limit:获取页面偏移量offset和页面大小pageSize,"":获取当前页数pageNumber和页面大小pageSize
        responseHandler: function responseHandler(response) {
            return {
                rows: response.data,
                total: response.total
            };
        },
        search: false, //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
        contentType: "application/x-www-form-urlencoded",
        strictSearch: true,
        showColumns: true, //是否显示所有的列
        showRefresh: true, //是否显示刷新按钮
        minimumCountColumns: 2, //最少允许的列数
        clickToSelect: true, //是否启用点击选中行
        uniqueId: "no", //每一行的唯一标识，一般为主键列
        showToggle: true, //是否显示详细视图和列表视图的切换按钮
        cardView: false, //是否显示详细视图
        detailView: false, //是否显示父子表
        icons: {
            refresh: 'fa fa-refresh',
            detailOpen: 'fa fa-tasks',
            toggle: 'fa fa-exchange'
        },
        onLoadSuccess: function onLoadSuccess(res) {
            //加载成功时执行
            layer.msg("加载成功", { time: 1000 });
        },
        onLoadError: function onLoadError() {
            //加载失败时执行
            layer.msg("加载数据失败");
        }
    },
    /**
     * 确认框
     * @param url
     * @param data
     * @param title
     * @param content
     */
    confirm: function confirm(url) {
        var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
        var callback = arguments[2];
        var title = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '你确定删除么？';
        var content = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : '删除后将无法恢复';

        layer.confirm(content, { icon: 3, title: title }, function (index) {
            axios.post(url, data).then(function (response) {
                if (callback) {
                    callback.call(null, response, data);
                } else {
                    utils.showToastr(response.data, 'go');
                }
            }).catch(function (error) {
                if (error.response) {
                    utils.showToastr({
                        'status': 'error',
                        'title': error.response.title,
                        'message': error.response.message
                    });
                } else if (error.request) {
                    console.log(error.request);
                } else {
                    utils.showToastr({ 'status': 'error', 'title': '请求错误', 'message': error });
                }
            });

            layer.close(index);
        });
    },
    /**
     * 页面跳转，重定向
     * @param url 跳转链接
     * @param times 等待时间
     */
    redirect: function redirect(url) {
        var times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;

        if (times > 0) {
            setTimeout(function () {
                window.location.href = url;
            }, times);
        } else {
            window.location.href = url;
        }
    },
    /**
     * 页面刷新
     * @param times 等待时间
     */
    reload: function reload() {
        var times = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000;

        if (times) {
            setTimeout(function () {
                window.location.reload();
            }, times);
        } else {
            window.location.reload();
        }
    },
    /**
     * 页面返回
     * @param times 等待时间
     */
    goback: function goback() {
        var times = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000;

        if (times) {
            setTimeout(function () {
                window.history.back(-1);
            }, times);
        } else {
            window.history.back(-1);
        }
    },
    /**
     * 异步post请求
     * @param posturl
     * @param data
     * @param callback
     */
    ajaxPost: function ajaxPost(posturl) {
        var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
        var callback = arguments[2];

        axios.post(posturl, data).then(function (response) {
            if (callback) {
                callback.call(null, response, data);
            } else {
                utils.showToastr(response.data, 'go');
            }
        }).catch(function (error) {
            if (error.response) {
                utils.showToastr({
                    'status': 'error',
                    'title': error.response.title,
                    'message': error.response.message
                });
            } else if (error.request) {
                console.log(error.request);
            } else {
                utils.showToastr({ 'status': 'error', 'title': '请求错误', 'message': error });
            }
        });
    },
    /**
     * 异步get请求
     * @param posturl
     * @param data
     * @param callback
     */
    ajaxGet: function ajaxGet(geturl) {
        var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
        var callback = arguments[2];

        axios.get(geturl, {
            params: data
        }).then(function (response) {
            if (callback) {
                callback.call(null, response, data);
            } else {
                utils.showToastr(response.data, 'go');
            }
        }).catch(function (error) {
            if (error.response) {
                utils.showToastr({
                    'status': 'error',
                    'title': error.response.title,
                    'message': error.response.message
                });
            } else if (error.request) {
                console.log(error.request);
            } else {
                utils.showToastr({ 'status': 'error', 'title': '请求错误', 'message': error });
            }
        });
    },
    /**
     * 异步提交表单
     * @param posturl
     * @param data
     */
    ajaxSubmitForm: function ajaxSubmitForm(form, posturl) {
        var otherData = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
        var callback = arguments[3];

        var params = $(form).serializeArray();
        var formData = {};
        for (x in params) {
            formData[params[x].name] = params[x].value;
        }
        var postdata = _.merge(formData, otherData);
        posturl = posturl ? posturl : $(form).attr('action');
        if (!posturl) {
            console.log('表单提交路径为空');
        }
        axios.post(posturl, postdata).then(function (response) {
            if (callback) {
                callback.call(null, response, postdata);
            } else {
                utils.showToastr(response.data, 'go');
            }
        }).catch(function (error) {
            if (error.response) {
                utils.showToastr({
                    'status': 'error',
                    'title': error.response.title,
                    'message': error.response.message
                });
            } else if (error.request) {
                console.log(error.request);
            } else {
                utils.showToastr({ 'status': 'error', 'title': '请求错误', 'message': error });
            }
        });
    }
};

/***/ }),

/***/ 41:
/***/ (function(module, exports, __webpack_require__) {

module.exports = __webpack_require__(42);


/***/ }),

/***/ 42:
/***/ (function(module, exports, __webpack_require__) {

/**
 * 载入项目引导文件
 */
__webpack_require__(0);

/**
 * 载入自定义工具
 */

__webpack_require__(1);

var box = void 0;

//增加
var add = function add() {
    var parent_id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;

    //加载父级菜单选择项
    //loadOption(parent_id);
    $("#box-form input[name='parent_id']").val(parent_id);
    $("#box-form form").resetForm();
    $("#box-form input[name='perm_id']").val(0);
    $("#box-form input[name='is_public'][value=0]").attr('checked', true);
    $("#box-form input[name='is_opentree'][value=1]").attr('checked', true);
    box = layer.open({
        type: 1,
        title: parent_id ? '添加子权限' : '添加权限',
        anim: 2,
        shadeClose: true, //开启遮罩关闭
        skin: 'layui-layer-molv', //加上边框
        area: ['620px', '600px'], //宽高
        content: $('#box-form')
    });
};
//修改
var edit = function edit(id) {
    $(".modal-title").html('编辑权限');
    utils.ajaxGet(page_params.url_get, {
        'id': id
    }, function (response) {
        var data = response.data;
        if (data.data == null) {
            toastr.error('数据不存在', '错误');
            return false;
        }
        $("#box-form input[name='perm_id']").val(data.data.perm_id);
        $("#box-form input[name='parent_id']").val(data.data.parent_id);
        $("#box-form input[name='display_name']").val(data.data.display_name);
        $("#box-form input[name='name']").val(data.data.name);
        $("#box-form textarea[name='description']").val(data.data.description);
        var is_public = data.data.is_public;
        $("#box-form input[name='is_public'][value=" + is_public + "]").prop('checked', 'checked');
        var is_opentree = data.data.is_opentree;
        $("#box-form input[name='is_opentree'][value=" + is_opentree + "]").prop('checked', 'checked');
        //$("#box-form select[name='parent_id']").val(data.data.parent_id);
        //加载父级菜单选择项
        //loadOption(data.data.parent_id);
        box = layer.open({
            type: 1,
            title: '修改权限',
            anim: 2,
            shadeClose: true, //开启遮罩关闭
            skin: 'layui-layer-molv', //加上边框
            area: ['620px', '600px'], //宽高
            content: $('#box-form')
        });
    });
};
$(document).ready(function () {
    //加载树结构
    $('#jstree').jstree({
        'core': {
            "multiple": false,
            'check_callback': true,
            "themes": {
                "variant": "large"
            },
            'data': {
                'url': page_params.url_list,
                'data': function data(node) {
                    //return {'id' : node.id};
                }
            }
        },
        'types': {
            'default': {
                'icon': 'fa fa-folder'
            }
        },
        "checkbox": {
            "keep_selected_style": false
        },
        "plugins": ['types', 'dnd', 'wholerow', 'unique', 'contextmenu'],
        "contextmenu": {
            "items": {
                "create": null,
                "rename": null,
                "remove": null,
                "ccp": null,
                "add": {
                    "label": "添加子项",
                    "action": function action(obj) {
                        var inst = jQuery.jstree.reference(obj.reference);
                        var clickedNode = inst.get_node(obj.reference);
                        add(clickedNode.id);
                    }
                },
                "edit": {
                    "label": "编辑",
                    "action": function action(obj) {
                        var inst = jQuery.jstree.reference(obj.reference);
                        var clickedNode = inst.get_node(obj.reference);
                        edit(clickedNode.id);
                    }
                },
                "delete": {
                    "label": "删除",
                    "action": function action(obj) {
                        var inst = jQuery.jstree.reference(obj.reference);
                        var clickedNode = inst.get_node(obj.reference);
                        utils.confirm(page_params.url_del, { 'ids': [clickedNode.id] }, function (response, postdata) {
                            data = response.data;
                            utils.showToastr(data);
                            if (data.status == 'success') {
                                //重新加载树结构
                                var tree = $.jstree.reference("#jstree");
                                tree.refresh();
                            }
                        });
                    }
                }
            }
        }
    });
    //移动事件
    $('#jstree').on('move_node.jstree', function (e, data) {
        utils.ajaxPost(page_params.url_sort, {
            id: data.node.id,
            parent: data.parent,
            position: data.position
        }, function (response, postdata) {
            data = response.data;
            utils.showToastr(data);
            if (data.status == 'success') {
                //重新加载树结构
                var tree = $.jstree.reference("#jstree");
                tree.refresh();
            }
        });
    });
    //表单
    /*$('.i-checks').iCheck({
        checkboxClass: 'icheckbox_square-green',
        radioClass: 'iradio_square-green',
    });*/
    $('#btn-sub').on('click', function () {
        utils.ajaxSubmitForm($("#box-form form"), '', {}, function (response, postdata) {
            data = response.data;
            utils.showToastr(data);
            if (data.status == 'success') {
                layer.close(box);
                //重新加载树结构
                var tree = $.jstree.reference("#jstree");
                tree.refresh();
            }
        });
    });
    //弹窗
    $(".add").on('click', function () {
        add(0);
    });
    $(".addchild").on('click', function () {
        var ref = $('#jstree').jstree(true),
            sel = ref.get_selected();
        if (!sel.length) {
            toastr.error('请选中您想要添加子项的权限', '错误');
            return false;
        }
        add(sel[0]);
    });
    $(".edit").on('click', function () {
        var ref = $('#jstree').jstree(true),
            sel = ref.get_selected();
        if (!sel.length) {
            toastr.error('请选中您想要编辑的权限', '错误');
            return false;
        }
        edit(sel[0]);
    });
    $(".del").on('click', function () {
        var ref = $('#jstree').jstree(true),
            sel = ref.get_selected();
        if (!sel.length) {
            toastr.error('请选中您想要删除的权限', '错误');
            return false;
        }
        utils.confirm(page_params.url_del, { 'ids': sel }, function (response, postdata) {
            data = response.data;
            utils.showToastr(data);
            if (data.status == 'success') {
                //重新加载树结构
                var tree = $.jstree.reference("#jstree");
                tree.refresh();
            }
        });
    });
});

/***/ })

},[41]);